<?php
session_start();
$totalprice=0;
function buttonC($id,$str,$act="",$style="")
{
echo "<input id=\"bc{$id}\" type=\"submit\"  class=\"exclusive\"  value=\"$str\" $style $act >";	
}
if($_POST['pid'] && $_POST['act']=="check"){
	if(!empty($_SESSION["ses_cart"]))
	{
	if($_POST['currstock']==0)
	buttonC($_POST['pid'],"สินค้าหมด","","style=\"background-image:url(img/button-account.gif)\"");
	else if($_SESSION["ses_cart"][$_POST['pid']]["quantity"]-$_POST['currstock']>$_POST['currstock'])
	buttonC($_POST['pid'],"หยิบใส่ตะกร้า","onClick=\"addCart('".$_POST['pid']."');checkCart('".$_POST['pid']."')\"");
	else if($_SESSION["ses_cart"][$_POST['pid']]["quantity"]-$_POST['currstock']==0)
	buttonC($_POST['pid'],"คุณเลือกสินค้าหมดแล้ว","","style=\"background-image:url(img/button-account.gif)\"");	
	else	if($_POST['currstock']>0)
	buttonC($_POST['pid'],"หยิบใส่ตะกร้า","onClick=\"addCart('".$_POST['pid']."');checkCart('".$_POST['pid']."')\"");
	}
	else
	{
		if($_POST['currstock']>0)
		buttonC($_POST['pid'],"หยิบใส่ตะกร้า","onClick=\"addCart('".$_POST['pid']."');checkCart('".$_POST['pid']."')\"");
		else
		buttonC($_POST['pid'],"สินค้าหมด","","style=\"background-image:url(img/button-account.gif)\"");
	}
}
?>